<?php
class Ruc extends Component  {
    var $ruc=null;
	//$this->Ruc->validar_ruc($ruc);
    function validar_ruc($ruc){
	
	if(strlen(trim($ruc))==11){
		$a = substr($ruc, 0, 1)*5;
		$b = substr($ruc, 1, 1)*4;
		$c = substr($ruc, 2, 1)*3;
		$d = substr($ruc, 3, 1)*2;
		$e = substr($ruc, 4, 1)*7;
		$f = substr($ruc, 5, 1)*6;
		$g = substr($ruc, 6, 1)*5;
		$h = substr($ruc, 7, 1)*4;
		$i = substr($ruc, 8, 1)*3;
		$j = substr($ruc, 9, 1)*2;
		$k = substr($ruc, 10, 1);
		
		$wsuma = $a+$b+$c+$d+$e+$f+$g+$h+$i+$j;
		$wresto = $wsuma%11;
		$wcomplemento = 11-$wresto;		
		
		if($wcomplemento!= $k){
			return false;
		}else{
			if(($wresto=1 & $k=0)||($wresto=0 & $k=1)){
				return false;
			}else{
				return true;
			}
		}
	}else{
		return false;
	}
}

}
?>